package ysother

import (
	"github.com/gogf/gf/v2/encoding/gjson"
	"github.com/gogf/gf/v2/encoding/gtoml"
	"github.com/gogf/gf/v2/encoding/gyaml"
)

type iCfgEncoder interface {
	name() string
	encode(v interface{}) ([]byte, error)
}

type yamlEncode struct {
}

func (*yamlEncode) name() string {
	return "yaml"
}

func (*yamlEncode) encode(v interface{}) ([]byte, error) {
	return gyaml.Encode(v)
}

type tomlEncode struct {
}

func (*tomlEncode) name() string {
	return "toml"
}

func (*tomlEncode) encode(v interface{}) ([]byte, error) {
	return gtoml.Encode(v)
}

type jsonEncode struct{}

func (*jsonEncode) name() string {
	return "json"
}

func (*jsonEncode) encode(v interface{}) ([]byte, error) {
	return gjson.Encode(v)
}
